home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / JAVA Utilities / JProxy 1.1.0 / customers / buy-customer.jsp < prev    next >
Encoding:
Text File  |  2003-04-29  |  10.0 KB  |  265 lines

  1. <%@ page language="java" import="
  2.     java.util.*,
  3.     com.jproxy.site.mbeans.JMXInvocator,
  4.     com.jproxy.site.mbeans.config.*,
  5.     com.jproxy.site.ejbeans.interfaces.ISaleFormula,
  6.     com.jproxy.site.ejbeans.interfaces.IProduct,
  7.     com.jproxy.site.*"
  8. %>
  9.  
  10. <jsp:useBean id="buycustomers" scope="request" class="com.jproxy.site.customers.Buy"/>
  11. <%
  12. buycustomers.request(pageContext);
  13. buycustomers.ses.setNewHit(pageContext, "hits", "Customer Buy Page", null);
  14. %>
  15.  
  16. <%
  17. int licenses = 1;
  18. int purchasedLicenses = 0;
  19. int support_licenses = 0;
  20. String productName = "";
  21.  
  22. String productID = buycustomers.getParameter("productid").trim();
  23. if(buycustomers.getParameter("licenses").trim().length()>0)
  24.     licenses = new Integer(buycustomers.getParameter("licenses")).intValue();
  25. if(buycustomers.getParameter("purchased-licenses").length()>0)
  26.     purchasedLicenses = new Integer(buycustomers.getParameter("purchased-licenses")).intValue();
  27. if(buycustomers.getParameter("support_licenses").length()>0)
  28.     support_licenses = new Integer(buycustomers.getParameter("support_licenses")).intValue();
  29.  
  30. if(productID.length()>0)
  31.     productName = buycustomers.product.getProductName();
  32. else
  33. {
  34. %>
  35.     <span class="h9Verdana">Failed to obtain Product Id!
  36.     Please report this error to <a class="h8VerdanaBold" href="mailto:postmaster@jproxy.com">postmaster@jproxy.com</a></span>
  37. <%
  38.     return;
  39. }
  40.  
  41. // find out the number of licenses requested
  42. if(licenses <= 0)
  43.     licenses = 1;
  44. // find out the number of licenses requested
  45. if(support_licenses < 0)
  46.     support_licenses = 1;
  47.  
  48. boolean isDisabled = false;
  49. String host = "http://"+request.getServerName()+":"+request.getServerPort();
  50.  
  51. String customerName = buycustomers.customer.getCustomerName();
  52. ISaleFormula formula = (ISaleFormula)buycustomers.getSaleFormulaByProductID(productID);
  53.  
  54. int invoice = 0;
  55. int customerId = 0;
  56.  
  57. int StandardSupportDuration = 30;
  58. int AdvancedSupportDuration = 90;
  59.  
  60. int firstLicensePrice = formula.getFirstLicense();
  61. int additionalLicensePrice = formula.getAdditionalLicense();
  62. //if(purchasedLicenses>0)
  63. //    firstLicensePrice = additionalLicensePrice;
  64.  
  65. // calculate the TOTAL AMOUNT based on the number of licenses and the pricing model
  66. double lic_cost = firstLicensePrice * buycustomers.formula.getDiscount();
  67. lic_cost += (licenses-1) * additionalLicensePrice * buycustomers.formula.getDiscount();
  68. double sup_cost = lic_cost * buycustomers.formula.getSupport() * support_licenses;
  69.  
  70. if(request.getParameter("submit_recalculate")!=null)
  71. {
  72. }
  73. if(request.getParameter("submit_purchase")!=null && request.getParameter("error")==null)
  74. {
  75. %>
  76.     <jsp:forward page="purchase.jsp"/>
  77. <%
  78. }
  79. %>
  80.   <!-- HEADER -->
  81.   <jsp:include page="header.jsp" flush="true">
  82.     <jsp:param name="name" value="ePortal - Purchasing Licenses and Technical Support"/>
  83.     <jsp:param name="pageId" value="buy"/>
  84.   </jsp:include>
  85.  
  86. <!-- MAIN PANEL -->
  87. <%
  88. ConfigMBean mbean = (ConfigMBean)JMXInvocator.getMBean("JProxy:service=JProxyConfigMBean", ConfigMBean.class);
  89. //String productName = mbean.get("com.jproxy.proxy.name") + " " + mbean.get("com.jproxy.proxy.version");
  90. String invoiceStr = mbean.get("com.jproxy.commerce.invoice");
  91. try{
  92.     invoice = Integer.parseInt(invoiceStr);
  93. }
  94. catch(Exception e){
  95.     invoice = 15;
  96. }
  97. %>
  98.  
  99. <%
  100. String sProductDescr;
  101. %>
  102. <br>
  103.   <table class="h8Verdana" cellpadding="5" width="100%" border="0">
  104. <!-- Prolog -->
  105.     <tr>
  106.      <td>
  107.          You're about to purchase <span class="h8VerdanaBold"><%=buycustomers.product.getProductName()%></span> licenses.
  108.          Please enter the desired number of software license and the number of
  109.          <a target='home' href="/main/support.jsp#advanced">Advanced Support Packages</a>, which are
  110.          optional. The software comes with the <a target='home' href="/main/support.jsp#standard">Standard Support Package</a>
  111.          free of charge.
  112.          <p>
  113.          If you elect to purchase Advanced Support Package
  114.          please select the number of the packages you would like to purchase. If you would like to get longer
  115.          support please increase the number of support packages to get the desired support duration.
  116.          <p>
  117.          Once yo've entered desired number of licenses and support packages, please press the <Recalcualte> button
  118.          to get the updated price.
  119.          <p>
  120.     </td>
  121.         </tr>
  122.     <tr>
  123.      <td>
  124.              <form method="get" action="buy.jsp">
  125.         <table class="h9Verdana" width="100%" border="0" bgcolor="9c9cff" cellpadding="1" cellspacing="0">
  126.          <tr><td>
  127.            <%=productName%>
  128.          </td></tr>
  129.          <tr><td>
  130.              <table class="h9Verdana" width="100%"  border="0" bgcolor="white" cellpadding="5" cellspacing="3" >
  131.               <tr>
  132.                <td align="left" width="65%" bgcolor="#f6f6f6">
  133.                              Number of Licenses:
  134.                              <INPUT TYPE=HIDDEN NAME="customer-id" VALUE="<%=buycustomers.customerID%>">
  135.                              </td>
  136.                <td align="left" bgcolor="#f3f8ff">
  137.                              <input type="input" name="licenses" value="<%=licenses%>" size="3">
  138.                            </td>
  139.                            <td align="right" width="35%" bgcolor="#f3f8ff">
  140.                              Subtotal: <input type="text" name="total" READONLY value="$<%=lic_cost%>" size="10">
  141.                </td>
  142.               </tr>
  143.             </table>
  144.           </td></tr>
  145.   <!-- begin title -->
  146.           <tr><td>
  147.                   Advanced Support Package
  148.           </td></tr>
  149.   <!-- begin prices -->
  150.           <tr><td>
  151.              <table class="h9Verdana" width="100%" border="0" bgcolor="white" cellpadding="5" cellspacing="3" >
  152.               <tr>
  153.                <td align="left" width="65%" bgcolor="#f6f6f6">
  154.                  Number of Support Cycles:
  155.                            </td>
  156.                <td align="left" bgcolor="#f3f8ff">
  157.                  <input type="input" name="support_licenses" value="<%=support_licenses%>" size="3">
  158.                            </td>
  159.                            <td align="right" width="35%" bgcolor="#f3f8ff">
  160.                              Subtotal: <input type="text" name="total" READONLY value="$<%=sup_cost%>" size="10">
  161.                </td>
  162.               </tr>
  163.              </table>
  164.           </td></tr>
  165.   <!-- begin prices -->
  166.           <tr><td>
  167.              <table class="h9Verdana" width="100%" border="0" bgcolor="white" cellpadding="5" cellspacing="3" >
  168.               <tr>
  169.                            <td align="left" width="68%" bgcolor="#f3f8ff">
  170.                              <INPUT TYPE=SUBMIT NAME=submit_recalculate WIDTH="20" VALUE="Recalculate">
  171.                              <INPUT TYPE=HIDDEN NAME="productid" VALUE="<%=buycustomers.product.getID()%>">
  172.                              <INPUT TYPE=HIDDEN NAME="purchased-licenses" VALUE="<%=purchasedLicenses%>">
  173.                            </td>
  174.                            <td align="right" width="32%"bgcolor="#f3f8ff">
  175.                              Grand Total: <input type="text" name="total" READONLY value="$<%=lic_cost + sup_cost%>" size="10">
  176.                            </td>
  177.               </tr>
  178.             </table>
  179.           </td></tr>
  180.         </td></tr>
  181.               </table>
  182.             </form>
  183.            <table class="h9Verdana" width="100%" border="0" bgcolor="white" cellpadding="5" cellspacing="3" >
  184.             <tr>
  185.              <td align="left" bgcolor="#f3f8ff">
  186.         <%
  187.         if (support_licenses == 0)
  188.         {
  189.             sProductDescr = productName + " with Standard Support Package for " +
  190.                 Integer.toString(StandardSupportDuration) + " days";
  191.         }
  192.         else
  193.         {
  194.             sProductDescr = productName + " and Advanced Support Package for " +
  195.                 Integer.toString(support_licenses * AdvancedSupportDuration) + " days";
  196.         }
  197.         %>
  198.                <span class="h8Verdana">Your selection is: <%=licenses%> license(s) for <%=sProductDescr%>.</span>
  199.              </td>
  200.             </tr>
  201.              <tr>
  202.                <td class="h8Verdana" align="left">
  203.                   Before submitting your purchase order please read our <a class="h8VerdanaBold" target="_blank" href="<%=JSPRes.path%>/main/resources/docs/eula.pdf">License agreement</a></span>
  204.                   and also review our <a class="h8VerdanaBold" target="_blank" href="/main/content/refundpolicy.html">refund policy</a>
  205.                </td>
  206.              </tr>
  207.              <tr>
  208.                <td align="right">
  209.             <!-- begin purchase button -->
  210.                   <%
  211.                   String headerHTML = "<font size=30 color=#6331CE>JProxy</font>";
  212.                           headerHTML += "<font size=10 color=#9C00FF>.com</font>";
  213.                   String footerHTML = "<font size=2><em>Copyright 2001-2002, JProxy</em></font>";
  214.                   %>
  215.  
  216.     <%
  217.         sProductDescr = "Licenses # : "+licenses+" ($"+lic_cost+")";
  218.         if (support_licenses == 0)
  219.         {
  220.             sProductDescr += "<br>"+productName + " and Standard Support Package for " +
  221.                 Integer.toString(StandardSupportDuration) + " days : $"+sup_cost;
  222.         }
  223.         else
  224.         {
  225.             sProductDescr += "<br>"+productName + " and Advanced Support Package for " +
  226.                 Integer.toString(support_licenses * AdvancedSupportDuration) + " days : $"+sup_cost;
  227.         }
  228.     %>
  229.             <!-- begin purchase button -->
  230.                      <FORM METHOD=POST ACTION="https://secure.authorize.net/gateway/transact.dll">
  231.                        <INPUT TYPE=HIDDEN NAME="number_of_licenses" VALUE="<%=licenses%>">
  232.                     <INPUT TYPE=HIDDEN NAME="customer-id" VALUE="<%=buycustomers.customerID%>">
  233.                     <INPUT TYPE=HIDDEN NAME="parent-id" VALUE="<%=buycustomers.ses.getLogin().getID()%>">
  234.                        <INPUT TYPE=HIDDEN NAME="x_amount" VALUE="<%=lic_cost + sup_cost%>">
  235.                        <INPUT TYPE=HIDDEN NAME="x_Version" VALUE="3.0">
  236.                        <INPUT TYPE=HIDDEN NAME="x_Login" VALUE="jproxyllc">
  237.                        <INPUT TYPE=HIDDEN NAME="x_Show_Form" VALUE="PAYMENT_FORM">
  238.                        <INPUT TYPE=HIDDEN NAME="x_Cust_ID" VALUE="<%=customerId%>">
  239.                        <INPUT TYPE=HIDDEN NAME="x_Invoice_Num" VALUE="<%=invoice%>">
  240.                        <INPUT TYPE=HIDDEN NAME="x_Description" VALUE="<%=sProductDescr%>">
  241.                        <!-- INPUT TYPE=HIDDEN NAME="x_Logo_URL" VALUE="http://jproxy.com/main/resources/jproxy.gif" -->
  242.                        <INPUT TYPE=HIDDEN NAME="x_Header_HTML_Payment_Form" VALUE="<%=headerHTML%>">
  243.                        <INPUT TYPE=HIDDEN NAME="x_Footer_HTML_Payment_Form" VALUE="<%=footerHTML%>">
  244.                        <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_Method" VALUE="GET">
  245.                        <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_Text" VALUE="Click here to continue">
  246.                        <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_URL" VALUE="<%=host%>/main/customers/purchase.jsp;jsessionid=<%=request.getSession().getId()%>">
  247.                        <INPUT TYPE=SUBMIT NAME=submit_purchase WIDTH="20" VALUE="Purchase">
  248.                        <INPUT TYPE=HIDDEN NAME="productid" VALUE="<%=buycustomers.product.getID()%>">
  249.                       </FORM>
  250.                </td>
  251.         </tr>
  252.       </table>
  253.      </td>
  254.     </tr>
  255.  
  256.     <tr>
  257.      <td>
  258.            <p>
  259.      </td>
  260.     </tr>
  261.   </table>
  262.  
  263. <!-- FOOTER -->
  264. <jsp:include page="footer.jsp" flush="true"/>
  265.